
#include <mutex>
#include <condition_variable>
#include <atomic>
using namespace std;

#ifndef COUNTDOWN_LATCH_HPP
#define COUNTDOWN_LATCH_HPP

namespace tulun
{
    class CountDownLatch
    {
    private:
        std::atomic_int count_;
        std::mutex mutex_;
        std::condition_variable cond_;

    public:
        CountDownLatch(int count);
        ~CountDownLatch();
        void wait();
        void countDown();
        int getCount() const;
    };
} // namespace tulun

#endif